package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Lwkj;
import com.hbnu.system.service.LwkjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 论文科技一级学科(Lwkj)表控制层
 *
 * @author makejava
 * @since 2024-12-20 15:56:25
 */
@RestController
@RequestMapping("/lwkj")
@Api(tags = "论文-学科分类模块")
public class LwkjController  {
    /**
     * 服务对象
     */
    @Resource
    private LwkjService lwkjService;

    @ApiOperation("论文-学科分类添加")
    @PostMapping("/addLwkj")
    public Rest<Boolean> addLwkj(@RequestBody Lwkj lwkj){
        boolean add = lwkjService.addLwkj(lwkj);
        return add ? Rest.success():Rest.failed();
    }

    @ApiOperation("获取论文学科列表")
    @GetMapping("/getLwkj")
    public Rest<List<Lwkj>> getProjectcates(){
        List<Lwkj> projectcateList = lwkjService.getLwkjList();
        return Rest.success(projectcateList);
    }

    @ApiOperation("论文学科修改")
    @PostMapping("/updateLwkj")
    public Rest<Boolean> updateLwkj(@RequestBody Lwkj lwkj){
        boolean update = lwkjService.updateLwkj(lwkj);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("论文学科删除")
    @GetMapping("/deleteLwkj")
    public Rest<Boolean> deleteLwkj(String ID){
        boolean delete = lwkjService.deleteLwkj(ID);
        return delete ? Rest.success() : Rest.failed();
    }

    //根据学科名字进行查询
    @ApiOperation("根据论文学科名字进行查询")
    @GetMapping("/getLwkjByName")
    public Rest<List<Lwkj>> getLwkjByName(String Name){
        List<Lwkj> lwkjs= lwkjService.getByLwkjName(Name);
        return Rest.success(lwkjs);
    }
}

